package paginas;

import java.util.Locale;

import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import modelUtil.Configuracion;

/**
 * 
 * @author pablo
 * 
 */
//Esta clase crea la ventana principal del programa
//sobre la que se van añadiendo los distintos paneles
public class PaginaPrincipal {

	private static void createAndShowGUI() {
		// Create and set up the window.
		

		String idioma = Configuracion.instancia().getIdioma();

		if (idioma.equals("es_ES"))
			Locale.setDefault(new Locale("es", "ES"));
		if (idioma.equals("en_UK"))
			Locale.setDefault(new Locale("en", "UK"));
		if (idioma.equals("gl_ES"))
			Locale.setDefault(new Locale("gl", "ES"));

		JFrame frame = new JFrame("In-tic");
		JFrame.setDefaultLookAndFeelDecorated(false);
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		if(Configuracion.instancia().getCreditos().equals("Si")){
		frame.add(new PaginaCreditos(frame));}else{
			
			frame.add(new PaginaUsuarios(frame,0,13));
		}
		frame.pack();
		frame.setVisible(true);

	}

	/**
	 * 
	 * @param args
	 */
	public static void main(String[] args) {

		String lookAndFeel = null;
		try {
			// Set cross-platform Java L&F (also called "Metal")
			lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
			// lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
			// lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
			// lookAndFeel = UIManager.getSystemLookAndFeelClassName();

			UIManager.setLookAndFeel(lookAndFeel);
		} catch (UnsupportedLookAndFeelException e) {
			// handle exception
		} catch (ClassNotFoundException e) {
			// handle exception
		} catch (InstantiationException e) {
			// handle exception
		} catch (IllegalAccessException e) {
			// handle exception
		}

		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				UIManager.put("swing.boldMetal", Boolean.FALSE);
				createAndShowGUI();
			}
		});
	}
}
